//
//  BasketballTableHeaderView.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/23.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "BasketballTableHeaderView.h"

@implementation BasketballTableHeaderView


- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        
        self.headView = [[UIView alloc] initWithFrame:CGRectMake(kScreenIp6(20), kScreenIp6(10), kScreenWidth - kScreenIp6(20)*2, kScreenIp6(100))];
        [self addSubview:_headView];
        
        // 添加主客队 logo name
        CGFloat commonWidth = kScreenIp6(80);
        
        self.hostLogo = [[UIImageView alloc] init];
        self.guestLogo = [[UIImageView alloc] init];
        self.hostName = [[UILabel alloc] init];
        self.guestName = [[UILabel alloc] init];
        self.hostRanking = [[UILabel alloc] init];
        self.guestRanking = [[UILabel alloc] init];
        
        [self addlogoNameViewWithFrame:CGRectMake(0, 0, commonWidth, commonWidth) logo:self.guestLogo name:self.guestName ranking:self.guestRanking];
        [self addlogoNameViewWithFrame:CGRectMake(self.headView.bounds.size.width - commonWidth, 0, commonWidth, commonWidth) logo:self.hostLogo name:self.hostName ranking:self.hostRanking];
        
        
        CGFloat infoWidth = kScreenIp6(100);
        self.matchInfo = [[UIView alloc] initWithFrame:CGRectMake((self.headView.bounds.size.width - infoWidth)/2, kScreenIp6(10), infoWidth, commonWidth)];
        
        
        [self addMatchInfoView];
        
        
    }
    return self;
}

//加载主队和客队 信息
-(void)addMatchInfoView
{
    
    
    //主队比分
    self.hostScore = [[UILabel alloc] initWithFrame:CGRectMake(kScreenIp6(60), 0, kScreenIp6(40), kScreenIp6(40))];
    self.hostScore.textAlignment = NSTextAlignmentCenter;
    self.hostScore.textColor = [UIColor colorWithRed:0.266 green:0.643 blue:0.155 alpha:1.000];
    self.hostScore.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:30];
    self.hostScore.adjustsFontSizeToFitWidth = YES;
    [self.matchInfo addSubview:_hostScore];
    
    
    //冒号
    UILabel *maohao = [[UILabel alloc] initWithFrame:CGRectMake(kScreenIp6(40), 0, kScreenIp6(kScreenIp6(20)), kScreenIp6(40))];
    maohao.textAlignment = NSTextAlignmentCenter;
    maohao.textColor = [UIColor colorWithRed:0.266 green:0.643 blue:0.155 alpha:1.000];
    maohao.text = @":";
    maohao.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:30];
    [self.matchInfo addSubview:maohao];
    
    //客队比分
    self.guestScore = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenIp6(40), kScreenIp6(40))];
    self.guestScore.textAlignment = NSTextAlignmentCenter;
    self.guestScore.textColor = [UIColor colorWithRed:0.266 green:0.643 blue:0.155 alpha:1.000];
    self.guestScore.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:30];
    self.guestScore.adjustsFontSizeToFitWidth = YES;
    [self.matchInfo addSubview:_guestScore];
    
    
    //比赛时间
    self.matchTime = [[UILabel alloc] init];
    self.matchTime.frame = CGRectMake(0, kScreenIp6(50), kScreenIp6(100) , kScreenIp6(20));
    self.matchTime.font = [UIFont systemFontOfSize:13];
    self.matchTime.textAlignment = NSTextAlignmentCenter;
    self.matchTime.adjustsFontSizeToFitWidth = YES;
    self.matchTime.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];
    [self.matchInfo addSubview:_matchTime];
    
    
    
    //比赛状态
    self.matchState = [[UILabel alloc]init];
    self.matchState.frame = CGRectMake(0, kScreenIp6(70), kScreenIp6(100) , kScreenIp6(20));
    self.matchState.font = [UIFont systemFontOfSize:12];
    self.matchState.textAlignment = NSTextAlignmentCenter;
    self.matchState.adjustsFontSizeToFitWidth = YES;
    self.matchState.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];
    [self.matchInfo addSubview:_matchState];
    
    
    
    [self.headView addSubview:_matchInfo];
}




- (void)addlogoNameViewWithFrame:(CGRect)frame logo:(UIImageView *)logo name:(UILabel *)name ranking:(UILabel *)ranking
{
    UIView *logoNameView = [[UIView alloc] initWithFrame:frame];
    
    CGFloat logoWidth = kScreenIp6(50);
    logo.frame = CGRectMake(kScreenIp6(15), 0, logoWidth, logoWidth);
    [logoNameView addSubview:logo];
    
    name.frame = CGRectMake(0, logoWidth, logoWidth + kScreenIp6(30), kScreenIp6(30));
    name.font = [UIFont systemFontOfSize:15];
    name.textAlignment = NSTextAlignmentCenter;
    name.adjustsFontSizeToFitWidth = YES;
    [logoNameView addSubview:name];
    
    ranking.frame = CGRectMake(0, logoWidth + kScreenIp6(30), logoWidth + kScreenIp6(30), kScreenIp6(20));
    ranking.font = [UIFont systemFontOfSize:12];
    ranking.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];
    ranking.textAlignment = NSTextAlignmentCenter;
    ranking.adjustsFontSizeToFitWidth = YES;
    [logoNameView addSubview:ranking];
    
    [self.headView addSubview:logoNameView];
}



@end
